package net.lab1024.smartadmin.module.business.transaxle.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.smartadmin.common.domain.PageResultDTO;
import net.lab1024.smartadmin.common.domain.ResponseDTO;
import net.lab1024.smartadmin.module.business.transaxle.dao.TransaxleDao;
import net.lab1024.smartadmin.module.business.transaxle.domain.dto.TransaxleAddDTO;
import net.lab1024.smartadmin.module.business.transaxle.domain.dto.TransaxleQueryDTO;
import net.lab1024.smartadmin.module.business.transaxle.domain.dto.TransaxleUpdateDTO;
import net.lab1024.smartadmin.module.business.transaxle.domain.entity.TransaxleEntity;
import net.lab1024.smartadmin.module.business.transaxle.domain.vo.TransaxleExcelVO;
import net.lab1024.smartadmin.module.business.transaxle.domain.vo.TransaxleVO;
import net.lab1024.smartadmin.util.SmartBeanUtil;
import net.lab1024.smartadmin.util.SmartPageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * [ ������ ]
 *
 * @author �Ζ�
 * @version 1.0
 * @company ��������
 * @copyright (c)  ��������Inc. All rights reserved.
 * @date 2021-11-19 11:18:27
 * @since JDK1.8
 */
@Service
public class TransaxleService {

    @Autowired
    private TransaxleDao transaxleDao;

    /**
     * ���ݱ�Ų�ѯ
     */
    public Boolean select(String sn,Long id){
        return  transaxleDao.getBySn(id,sn).size()>0;
    }



    /**
     * ����id��ѯ
     */
    public TransaxleVO getById(Long id){
        return  transaxleDao.getById(id);
    }

    /**
     * ��ҳ��ѯ
     * @author �Ζ�
     * @date 2021-11-19 11:18:27
     */
    public ResponseDTO<PageResultDTO<TransaxleVO>> queryByPage(TransaxleQueryDTO queryDTO) {
        Page page = SmartPageUtil.convert2QueryPage(queryDTO);
        IPage<TransaxleVO> voList = transaxleDao.queryByPage(page, queryDTO);
        PageResultDTO<TransaxleVO> pageResultDTO = SmartPageUtil.convert2PageResult(voList);
        return ResponseDTO.succData(pageResultDTO);
    }

    /**
     * ���
     * @author �Ζ�
     * @date 2021-11-19 11:18:27
     */
    public ResponseDTO<String> add(TransaxleAddDTO addDTO) {
        TransaxleEntity entity = SmartBeanUtil.copy(addDTO, TransaxleEntity.class);
        transaxleDao.add(entity);
        return ResponseDTO.succ();
    }

    /**
     * �༭
     * @author �Ζ�
     * @date 2021-11-19 11:18:27
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> update(TransaxleUpdateDTO updateDTO) {
        TransaxleEntity entity = SmartBeanUtil.copy(updateDTO, TransaxleEntity.class);
        transaxleDao.update(entity);
        return ResponseDTO.succ();
    }

    /**
     * ɾ��
     * @author �Ζ�
     * @date 2021-11-19 11:18:27
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> deleteByIds(List<Long> idList) {
        transaxleDao.deleteByIdList(idList);
        return ResponseDTO.succ();
    }

    /**
     * ��ѯȫ����������
     * @author �Ζ�
     * @date 2021-11-19 11:18:27
     */
    public List<TransaxleExcelVO> queryAllExportData(TransaxleQueryDTO queryDTO) {
        return transaxleDao.queryAllExportData( queryDTO);
    }

    /**
     * ������ѯ��������
     * @author �Ζ�
     * @date 2021-11-19 11:18:27
     */
    public List<TransaxleExcelVO> queryBatchExportData(List<Long> idList) {
        return transaxleDao.queryBatchExportData(idList);
    }
}
